<extend name="Base/common" />
<block name="deskbody">
    

<div id="login-page" class='col-md-6 col-md-offset-3'>
    <br/>
    <div class="panel panel-primary">
        <div class="panel-heading">
            <p class="panel-title">{:C('CUSTOMER_NAME')}-<small>管理后台</small></p>
        </div>

        <div class="panel-body">
            <form action="{:U('login')}" method="post" id='loginform'>
                <div class="form-group form-group-lg has-feedback">
                <div class="input-group input-group-lg">
                    <span class="input-group-addon"><span class='glyphicon glyphicon-user text-primary'></span></span>
                    <input type="text" class="form-control" id="form-name" name="username" placeholder="请填写用户名" autocomplete="off" />
                </div>
                </div>

                <div class="form-group form-group-lg">
                <div class="input-group input-group-lg">
                    <span class="input-group-addon"><span class='glyphicon glyphicon-lock text-primary'></span></span>
                    <input type="password" class="form-control" id="form-pwd" name="password" placeholder="请填写密码" autocomplete="off" />
                </div>
                </div>

                <div class="form-group form-group-lg">
                <div class="input-group input-group-lg">
                    <span class="input-group-addon"><span class='glyphicon glyphicon-exclamation-sign text-primary'></span></span>
                    <input type="text" class="form-control" id="form-verify" name="verify" placeholder="请填写验证码" autocomplete="off">
                    <span class="input-group-addon"><a class="reloadverify" title="换一张" href="javascript:void(0)">换一张？</a></span>
                </div>
                </div>

                <div class="form-group form-group-lg text-center">
                <img class="verifyimg reloadverify" alt="点击切换" src="{:U('Public/verify')}">
                <hr/>
                <button type="submit" class="btn btn-primary btn-lg" id="submit">登 录</button>
                <br>
                <strong class='check-tips text-danger'></strong>
                </div>

<!--                         <div class="login_btn_panel">
                            <button class="login-btn" type="submit">
                                <span class="in"><i class="icon-loading"></i>登 录 中 ...</span>
                                <span class="on">登 录</span>
                            </button>
                            <div class="check-tips"></div>
                        </div>    -->             
            </form>
        </div>
        <div class="panel-footer text-muted text-right">
            <i>{:C('DESK_TITLE')}</i>
        </div>
    </div>
</div>


    <script type="text/javascript">
    	//表单提交
    	$(document)
	    	.ajaxStart(function(){
	    		$("#submit").attr("disabled", true).text('登录中...');
	    	})
	    	.ajaxStop(function(){
	    		$("#submit").attr("disabled", false).text('登 录');
	    	});

    	$("form").submit(function(){
    		var self = $(this);
            self.find(".check-tips").text("");
    		$.post(self.attr("action"), self.serialize(), success, "json");
    		return false;

    		function success(data){
    			if(data.status){
    				window.location.href = data.url;
    			} else {
    				self.find(".check-tips").text(data.info);
    				//刷新验证码
    				$(".reloadverify").click();
    			}
    		}
    	});

		$(function(){
			//初始化选中用户名输入框
			$("#itemBox").find("input[name=username]").focus();
			//刷新验证码
			var verifyimg = $(".verifyimg").attr("src");
            $(".reloadverify").click(function(){
                if( verifyimg.indexOf('?')>0){
                    $(".verifyimg").attr("src", verifyimg+'&random='+Math.random());
                }else{
                    $(".verifyimg").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
                }
            });

            //placeholder兼容性
                //如果支持 
            function isPlaceholer(){
                var input = document.createElement('input');
                return "placeholder" in input;
            }
                //如果不支持
            if(!isPlaceholer()){
                $(".placeholder_copy").css({
                    display:'block'
                })
                $("#itemBox input").keydown(function(){
                    $(this).parents(".item").next(".placeholder_copy").css({
                        display:'none'
                    })                    
                })
                $("#itemBox input").blur(function(){
                    if($(this).val()==""){
                        $(this).parents(".item").next(".placeholder_copy").css({
                            display:'block'
                        })                      
                    }
                })
                
                
            }
		});
    </script>

</block>
